package drds.global_transaction.resource_manager.execute;

import drds.global_transaction.resource_manager.proxy.resource_manager.StatementProxy;
import drds.global_transaction.resource_manager.sql_recognizer.SqlRecognizer;
import lombok.Getter;
import lombok.Setter;

import java.sql.Statement;

public class PlainExecutor<T, S extends Statement> implements Executor<Object>
{

	private StatementProxy<S> statementProxy;

	private StatementExecuteTemplate<T, S> statementExecuteTemplate;

	@Setter
	@Getter
	private SqlRecognizer sqlRecognizer;

	public PlainExecutor(SqlRecognizer sqlRecognizer, StatementProxy<S> statementProxy, StatementExecuteTemplate<T, S> statementExecuteTemplate)
	{
		this.statementProxy = statementProxy;
		this.statementExecuteTemplate = statementExecuteTemplate;
		this.sqlRecognizer = sqlRecognizer;
	}

	@Override
	public T execute(Object... args) throws Exception
	{
		return statementExecuteTemplate.execute(statementProxy.getStatement(), args);
	}
}
